class HtmlOutputer(object):
    def __init__(self):
        self.datas = []

    def collect_data(self, data):
        if data is None:
            return
        self.datas.append(data)

    def output_html(self):
        fout = open('output.html', 'w')

        fout.write("<html>")
        fout.write("<head><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\"></head>")
        fout.write("<body>")
        fout.write("<table>")

        for data in self.datas:
            fout.write("<tr>")
            fout.write("<td>url:%s</td>" % data['url'])
            fout.write("<td>title:%s</td>" % data['title'].encode('utf-8'))
            fout.write("<td>year:%s</td>" % data['year'].encode('utf-8'))
            fout.write("<td>score:%s</td>" % data['score'].encode('utf-8'))
            fout.write("<td>director:%s</td>" % data['director'].encode('utf-8'))
            fout.write("<td>host:%s</td>" % data['host'].encode('utf-8'))
            fout.write("<td>actor:%s</td>" % data['actor'].encode('utf-8'))
            fout.write("<td>duration:%s</td>" % data['duration'].encode('utf-8'))
            fout.write("<td>information:%s</td>" % data['information'].encode('utf-8'))
            fout.write("</tr>")

        fout.write("</table>")
        fout.write("</body>")
        fout.write("</html>")
        fout.close()
